<template>
  <div>
    <div id="supermap"></div>
  </div>
</template>
<script>
  export default {
    name: 'supermap',
    data () {
      return {
        map: '',
        markers: {},
        datasetInfo: ''
      }
    },
    methods: {
      /**
       * 地图初始化
       * @author chend(cdhahaha@163.com)
       * @createDate 2018-09-28
       */
      mapInit () {
        var gaodeMapLayer
        var url = 'http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}'
        this.map = L.map('supermap', {
          center: [25.412239, 107.8838],
          zoom: 9,
          control: []
        })
        gaodeMapLayer = L.tileLayer(url, { subdomains: "1234" })
        gaodeMapLayer.addTo(this.map)
      },
      /**
       * 标注图标初始化
       * @author chend(cdhahaha@163.com)
       * @createDate 2018-09-28
       * @param      {String}   options.url 图标地址
       * @return     {Object}               图标对象
       */
      markerIconInit ({ url }) {
        return L.icon({
          iconUrl: url,
          iconSize: [72, 72]
        })
      },
      /**
       * 获取锚点列表数据
       * @author chend(cdhahaha@163.com)
       * @createDate 2018-09-14
       */
      anchorListSearch () {
        var count = 900, lat = 23.412239, lng= 107.8838
        while (count > 0) {
          lng = count % 30 ? (lng + 0.2) : 104.838
          lat = count % 30 ? lat : (lat + 0.2)
          this.addMarker([lat.toFixed(4), lng.toFixed(4)])
          --count
        }
      },
      /**
       * 添加标注
       * @author chend(cdhahaha@163.com)
       * @createDate 2018-09-28
       */
      addMarker (lnglat) {
        var marker = L.marker(lnglat, {
          icon: this.markerIconInit({url: 'https://192.168.254.98:6100/fjxhx/gis/anchor/type/icon/show?anchorTypeId=_73B5EE02B027449DAEBB8330C7FE9DC8&status=011'}),
          draggable: true
        }).addTo(this.map).on('click', (e) => {
          console.log(e)
        })
      },
      /**
       * 点聚合
       * @author chend(cdhahaha@163.com)
       * @createDate 2018-09-28
       */
      summaryMesh () {
        console.log(SuperMap.SummaryMeshJobParameter)
      },
      /**
       * id搜索数据集
       * @author chend(cdhahaha@163.com)
       * @createDate 2018-09-28
       */
      searchonMap () {
        var idsParam = new SuperMap.GetFeaturesByIDsParameters({
          IDs: [246, 247],
          datasetNames: ['chend']
        })
        var url = 'http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data'
        L.supermap.featureService(url).getFeaturesByIDs(idsParam, (serviceResult) => {
          console.log(serviceResult)
        })
      },
      /**
       * 数据集初始化
       * @author chend(cdhahaha@163.com)
       * @createDate 2018-09-28
       */
      datasetInfoInit () {
      }
    },
    mounted () {
      this.mapInit()
      this.summaryMesh()
    }
  }
</script>
<style rel="stylesheet/less" lang="less">
  #supermap {
    position: absolute;
    height: 100%;
    width: 100%;
    z-index: 9999;
    left: 0;
    top: 0;
    right: 0;
  }
</style>
